/*
 * @Author: zcm
 * @Date: 2022-05-23
 */

import { ControlType as TYPE } from '@components'

const fields = (roleList, hiddden) => {
  const newRoleList = roleList.map(item => {
    const { roleId: value, roleName: label } = item
    return { value, label }
  })
  return [
    {
      name: 'roleId', label: '角色名称', controlType: TYPE.SELECT, options: newRoleList,
      showSearch: true,
      allowClear: true,
      optionFilterProp: "children",
      filterOption: (input, option) => option.children.toLowerCase()?.includes(input.toLowerCase()),
      mode: hiddden ? 'hidden' : ''
    },
    {
      name: 'unitCode', label: '机构名称', controlType: TYPE.SELECTBOTH, codeKey: "secondUnits",
      showSearch: true,
      allowClear: true,
      optionFilterProp: "children",
      filterOption: (input, option) => option.children.toLowerCase()?.includes(input.toLowerCase()),
      mode: hiddden ? 'hidden' : ''
    },
    { name: 'userName', label: '姓名', controlType: TYPE.INPUT },
    { name: 'userCode', label: '工号', controlType: TYPE.INPUT },
  ]
}

export default fields

